/**
 * 
 * purpose: BUBBLE BUTTON ...
 * @auth: Ning
 * date: 2009-10-9
 * 
 * */
package com.components.button
{
	import flash.display.DisplayObject;
	import flash.display.InteractiveObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;

	public class BubbleButton extends MCButton
	{
		//START...
		
		//PROPERTY...
		private var background:DisplayObject;
		
		private var bgRect:Rectangle;
		
		//CONSTRUCTOR...
		public function BubbleButton(target:DisplayObject)
		{
			super(target as MovieClip);
			
			init();
			
		}
		
		//METHODS...
		
		//initializing...
		private function init():void
		{
			
			var container:Sprite = target as Sprite
			
			background = (target as Sprite).getChildByName("background") as Sprite;
			
			container.mouseChildren = true;
			
			for(var i:int = 0;i < container.numChildren;i++)
			{
				
				if(container.getChildAt(i) is InteractiveObject && container.getChildAt(i) != background)
				{
					
					(container.getChildAt(i) as InteractiveObject).mouseEnabled = false;
										
				}	
				
			}
						
			target.addEventListener(MouseEvent.MOUSE_OVER,mouseHandler,false,1,true);
			
			target.addEventListener(MouseEvent.MOUSE_OUT,mouseHandler,false,1,true);
			
		}
		
		//mouse handler...
		private function mouseHandler(evt:MouseEvent):void
		{
			
			if(evt.target != background) evt.stopImmediatePropagation();
			
		}
		
		
		
		//END...
	}
}